package com.yingjia.yingjiauniversity.utils;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;

/**
 * <异常相关工具类>
 *
 * @author: guoxiangxun
 * @date: 16-10-24 下午3:27
 * @version: v1.0
 */
public class ExceptionUtil {
    private ExceptionUtil() {
        throw new AssertionError();
    }

    /**
     * 转换异常信息为String
     *
     * @param throwable the throwable
     * @return the error info
     */
    public static String getErrorInfo(Throwable throwable) {
        Writer writer = new StringWriter();
        PrintWriter printWriter = new PrintWriter(writer);
        throwable.printStackTrace(printWriter);
        printWriter.close();
        String error = writer.toString();
        return error;
    }
}
